package com.admin.dbdao;

import com.admin.bean.GoodSoftwareType;
import com.data.dbdao.BaseDao;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.util.List;

/**
 * 精选软件实体类
 *
 * @author:HingLo
 * @create 2017-09-30 16:44
 **/
@Repository
@Transactional
public class GoodSoftwareTypeDao extends BaseDao {
    private static Logger logger = Logger.getLogger(GoodSoftwareTypeDao.class);

    public List<?> findAllGoodSoftwareTypeDao() {
        String hql = "SELECT gt.id,gt.name,gt.ctime,gt.endtime,gt.contents,(SELECT COUNT(g.id) from GoodSoftware as g where g.gid=gt.id) as num,gt.type from GoodSoftwareType as gt ";
        return super.findMassageDao(hql);
    }

    public boolean updateGoodSoftwareAdminDao(String id) {
        String hql = "delete GoodSoftwareType where id=?";
        return super.updateManyMssageDao(hql, id) > 0;
    }

    public List<GoodSoftwareType> lookGoodSoftwareIconDao(String id) {
        String hql = "from GoodSoftwareType where id=? ";
        return (List<GoodSoftwareType>) super.findMassageDao(hql, id);
    }
}
